package com.bfs.config;/**
 * @Deacription TODO
 * @Author baohuajie
 * @Date 2020/12/14 13:43
 * @Version 1.0
 **/

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RoundRobinRule;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 *@Deacription TODO
 *@Author baohuajie
 *@Date 2020/12/14 13:43
 *@Version 1.0
 **/
@Configuration
public class MianConfig {

    /**
     * @loadBalance注解修饰的restTemplate才能实现服务名的调用，没有修饰的restTemplate是没有该功能的。
     * @return
     */
    @LoadBalanced
    @Bean
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }
    @Bean
    public IRule iRule() {
        return new RoundRobinRule();
    }
}
